/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package bsc.war.handler;


import bsc.ejb.entity.Project;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import bsc.war.test.XmlView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.math.NumberUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author luisZavaleta
 */
public class ProjectHandler extends AbstractController{

     @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
             HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView("selectUnit");


        try {
            DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");

            Document doc = DocumentHelper.createDocument();
            XmlView xv = new XmlView(doc);
            mav.setView(xv);

            Element root = doc.addElement("projects");
            Element pjct = root.addElement("project");

            Long id = null;
            if (NumberUtils.isDigits(request.getParameter("id"))) {
                id = Long.valueOf(request.getParameter("id"));
            } else {
                return mav;
            }

            Project project = delegate.findProject(id);

            //project.g
        } catch (Exception e) {
        }

        return mav;
    }

}
